package com.cn.medicalcare.service;

import com.cn.medicalcare.customtool.SqlSessionFactoryTool;
import com.cn.medicalcare.mapper.PageCountMapper;
import com.cn.medicalcare.pojo.Table;

public class PageCountService {

    public static final int PAGE_CAPACITY=8;

    //静态内部类单例模式
    private static class SingletonClassInstance{
        private static final PageCountService instance=new PageCountService();
    }

    private PageCountService(){}

    public static PageCountService getInstance(){
        return PageCountService.SingletonClassInstance.instance;
    }


    public Integer getPageCount(String tablename){
        int recordCount= SqlSessionFactoryTool.DoMapper(PageCountMapper.class,m->m.selectRecordCountByTableName(tablename));
        int num=recordCount/PAGE_CAPACITY;
        return recordCount%PAGE_CAPACITY==0?num:num+1;
    }
}
